<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">



<ui:composition template="/templates/template.xhtml">
	<ui:define name="pageTitle">Cadastro de Esportes</ui:define>
	<ui:define name="pageHeader">Cadastro de Esportes</ui:define>
	<ui:define name="body">

		<h:form id="edicao">

			<h:inputHidden value="#{esporteBean.esporteSelecionado.id}" />

			<h:panelGrid columns="2">
				<h:outputText value="Nome: " />
				<h:inputText value="#{esporteBean.esporteSelecionado.nome}" />
			</h:panelGrid>

			<h:messages />

			<h:commandButton action="#{esporteBean.novo}" value="Novo Esporte" />
			<h:commandButton action="#{esporteBean.salvar}" value="Salvar" />

		</h:form>


		<h:form id="lista">

			<h:dataTable value="#{esporteBean.lista}" var="esporteListado"
				border="1" rendered="#{not empty esporteBean.lista}">

				<h:column>
					<f:facet name="header">Cód.</f:facet>
						#{esporteListado.id}
				</h:column>

				<h:column>
					<f:facet name="header">Nome</f:facet>
						#{esporteListado.nome}
				</h:column>

				<h:column>
					<f:facet name="header">Ações</f:facet>

					<h:commandLink action="#{esporteBean.excluir}"	onclick="if(!confirm('Deseja excluir o esporte #{esporteListado.nome}?')) return false;">
						<h:graphicImage value="/resources/images/trash-icon24px.png" />
						<f:setPropertyActionListener target="#{esporteBean.esporteSelecionado}" value="#{esporteListado}" />
					</h:commandLink>

					<h:commandLink>
						<h:graphicImage value="/resources/images/wrench-icon-24px.png" />
						<f:setPropertyActionListener target="#{esporteBean.esporteSelecionado}" value="#{esporteListado}" />
					</h:commandLink>
				</h:column>

			</h:dataTable>

		</h:form>


	</ui:define>
</ui:composition>

</html>